//
//  IJIssuePicCell.m
//  iwjw
//
//  Created by ChenJianjun on 2016/12/14.
//  Copyright © 2016年 iwujwu. All rights reserved.
//

#import "IJIssuePicCell.h"

@interface IJIssuePicCell ()

@property (nonatomic, strong) UIImageView *picView;
@property (nonatomic, strong) UIButton *deleteBtn;

@end

@implementation IJIssuePicCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _picView = [[UIImageView alloc] init];
        [self.contentView addSubview:_picView];
        [_picView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.bottom.mas_equalTo(0);
            make.top.mas_equalTo(8);
            make.trailing.mas_equalTo(-8);
        }];
        
        _deleteBtn = [[UIButton alloc] init];
        [_deleteBtn setImage:[UIImage imageNamed:@"删除"] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_deleteBtn];
        [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(2);
            make.trailing.mas_equalTo(-2);
            make.width.height.mas_equalTo(20);
        }];
    }
    return self;
}

- (void)setPic:(UIImage *)pic
{
    _pic = pic;
    self.picView.image = pic;
}

- (void)deleteAction:(id)sender
{
    if (self.deleteBlock) {
        self.deleteBlock(self.pic);
    }
}

@end
